Skip to content

fix: Typing on toHaveHTML should allow HTMLOptions#2090

Merged
dprevost-LMI merged 1 commit into
webdriverio:mainfrom
dprevost-LMI:fix-typing-not-allowing-HTMLOptions-with-toHaveHTML
May 3, 2026
Merged

fix: Typing on toHaveHTML should allow HTMLOptions#2090
dprevost-LMI merged 1 commit into
webdriverio:mainfrom
dprevost-LMI:fix-typing-not-allowing-HTMLOptions-with-toHaveHTML

Conversation

@dprevost-LMI
Copy link
Copy Markdown
Contributor

@dprevost-LMI dprevost-LMI commented May 2, 2026

Fixes #2089
toHaveHTML should be using HTMLOptions and not only StringOptions to allow passing includeSelectorTag

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 2, 2026

Greptile Summary

This PR fixes a type-declaration mismatch in toHaveHTML: the public .d.ts was typed with StringOptions while the runtime implementation (src/matchers/element/toHaveHTML.ts) already accepted HTMLOptions (which extends StringOptions with includeSelectorTag). The fix aligns the declaration with the implementation and adds a mocha type test to validate the corrected signature.

Confidence Score: 5/5

Safe to merge — the change is a one-line type correction that aligns the public declaration with the existing runtime implementation.

The fix is minimal, correct, and backward-compatible (HTMLOptions extends StringOptions). The implementation already used HTMLOptions internally, so no runtime behavior changes. Only a P2 style observation about missing parallel type tests in other framework files.

No files require special attention.

Important Files Changed

Filename Overview
types/expect-webdriverio.d.ts Changed toHaveHTML option type from StringOptions to HTMLOptions, which correctly extends StringOptions with includeSelectorTag. The implementation already used HTMLOptions, so this aligns the declaration with runtime behavior.
test-types/mocha/types-mocha.test.ts Added a type-level test verifying toHaveHTML accepts { includeSelectorTag: true }. Only the mocha variant was updated; the jasmine/jest equivalents were not, though this is non-blocking since the shared .d.ts covers all frameworks.

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class CommandOptions {
        +message?: string
    }
    class StringOptions {
        +ignoreCase?: boolean
        +trim?: boolean
        +containing?: boolean
    }
    class HTMLOptions {
        +includeSelectorTag?: boolean
    }
    CommandOptions <|-- StringOptions
    StringOptions <|-- HTMLOptions

    class toHaveHTML {
        +html: string | RegExp | PartialMatcher | Array
        +options?: HTMLOptions
    }
    toHaveHTML --> HTMLOptions : uses (was StringOptions)
Loading

Reviews (1): Last reviewed commit: "fix: Typing on toHaveHTML should allow H..." | Re-trigger Greptile

Comment thread test-types/mocha/types-mocha.test.ts
@dprevost-LMI dprevost-LMI merged commit 9b4a88b into webdriverio:main May 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

toHaveHTML type declaration has wrong / incomplete type for options

1 participant